import service from "@/utils/request"

import LoginWork from "@/utils/LoginWork" 
// 插入指令材料查询
export interface InsertInstructionMaterialQueryParms{
    lotNo:string,
    mtlName:string,
    pageNum:number,
    pageSize:number,
    style:string,
    typeNo:string
}

export interface InsertInstructionMaterialQueryTableDateList {
    dtos:InsertInstructionDtos[],
    total?:number
}

interface InsertInstructionDtos{
    lotNo: string,
    seqNo: number,
    partName: string,
    segment: number,
    mtlTypeNo: string,
    mtlType: string,
    mtlNo: string,
    mtlColor: string,
    mtlName: string,
    mtlSpec: null,
    mtlUnit: string,
    ttlUsage: number,
    stkQty: number
}

export const InsertInstructionMaterialQuery = (parms:InsertInstructionMaterialQueryParms) => {
    return service.put<any,InsertInstructionMaterialQueryTableDateList>('/pcFactorStockQuery/getMTSLotMtlQuery',parms)
}

// 贴合子材料查询
export interface FitSubMaterialConditionsInterface{
    mtlNo: string,
    mtlColor: string,
    mtlName: string,
    mtlSpec: string,
    mtlUnit: string,
    percent: string,
    purFlag: string
}

export const FitSubMaterialConditions = (mtlNo:string) => {
    return service.post<any,FitSubMaterialConditionsInterface[]>(`/pcFactorStockQuery/otherLotSubMtlQuery2?mtlNo=${mtlNo}`)
}

// 插入型体材料查询
export interface InsertTypeMaterialQueryParms{
    mtlName:string,
    mtlTypeNo:string,
    pageNum:number,
    pageSize:number,
    styleColor:string,
    styleNo:string
}

export interface InsertTypeMaterialQueryInterface{
    total?:number
    dtos:InsertDtos[]
}

interface InsertDtos{
    styleNo: null,
    styleColor: null,
    seqNo: number,
    partName: string,
    segment: 0,
    mtlType: string,
    mtlNo: string,
    mtlColor: string,
    mtlName: string,
    mtlSpec: null,
    mtlUnit: string,
    stkQty: null
}

export const InsertTypeMaterialQuery = (parms:InsertTypeMaterialQueryParms) => {
    return service.put<any,InsertTypeMaterialQueryInterface>(`/pcFactorStockQuery/getMTSStyleMtlQuery`,parms)
}

// 材料库存
export interface MaterialStockClothParms{
    mtlColor:string,
    mtlName:string,
    mtlNo:string,
    mtlType:string,
    pageNum:number,
    pageSize:number,
    stkFlag:number
}

export interface MaterialStockClothInterface{
    total?:number
    dtos:dtosList[]
}

interface dtosList{
    mtlNo: string,
    mtlName: string,
    mtlSpec: string,
    mtlUnit: string,
    stkQty: number,
    STK_SUM: number
}

export const MaterialStockCloth = (parms:MaterialStockClothParms) => {
    return service.put<any,MaterialStockClothInterface>('/back/getMtlSub',parms)
}

// 待入剩料仓查询
export const DetailsOfRemainingBinToBeFilled = () => {
    return service.get<any,any>('/pcFactorStockQuery/getMTSTempQuery')
}

// 剩料入库明细查询
export interface QueryDetailsOfRemainingMaterialsInStorageParms{
    slipDateEnd:string,
    slipDateStart:string,
    slipNo:string,
    slipReason:string,
    type:string
}

export interface QueryDetailsOfRemainingMaterialsInStorageInterface{
    slipNo: string,
    slipDate: string,
    slipReason: number,
    lotNo: null,
    mtlColor: null,
    mtlName: string,
    mtlSpec: string,
    mtlUnit: string,
    qty: number,
    remark: string,
    mtlNo: string,
    deptName: null,
    price: null,
    amt: null,
    sysUser: string
}

export const QueryDetailsOfRemainingMaterialsInStorage = (parms:QueryDetailsOfRemainingMaterialsInStorageParms) => {
    return service.put<any,QueryDetailsOfRemainingMaterialsInStorageInterface[]>(`/pcFactorStockQuery/getMTSDetailQuery`,parms)
}

// 待入剩料删除
export const RemainingMaterialToBeRemoved = (mtlNo:string) => {
    return LoginWork.post<any,any>(`/pcFactorStockQuery/mTSTempDelete?mtlNo=${mtlNo}`)
}

// 删除当前行记录
export const DeleteTheCurrentRow = (mtlNo:string,slipNo:string) => {
    return LoginWork.post<any,any>(`/pcFactorStockQuery/mTSDetailDelete?mtlNo=${mtlNo}&slipNo=${slipNo}`)
}

// 转入待入剩料系新增
export interface EnterThePendingAdditionParms{
    type?:number,
    request:any[]
}

export const EnterThePendingAddition = (type:number,parms:EnterThePendingAdditionParms) => {
    return LoginWork.put<any,any>(`/pcFactorStockQuery/mTSTempAdd?type=${type}`,parms)
}

// 剩料入库明细新增
export const TheDetailsOfRemainingMaterialsInStorageWereAdded = (mtlNo:string,slipReason:string,slipDate:string) => {
    return LoginWork.post<any,any>(`/pcFactorStockQuery/mTSDetailAdd?mtlNo=${mtlNo}&slipReason=${slipReason}&slipDate=${slipDate}`)
}